Skip to content

Add active series limit for nativeHistogram samples #6796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

PaurushGarg
Copy link
Contributor

@PaurushGarg PaurushGarg commented Jun 6, 2025

What this PR does:
In addition to the current activeSeries limit on float+histogram samples, this PR adds an active series limit for specifically for nativeHistogram
samples.
This is done, b/c the ingestion of native histogram samples is much more CPU intensive than that of float samples - adding nativeHistogram samples specific ingestions limit to protect the service and to allow clients to adjust the NH series ingestion.

Currently, Prometheus doesn't provide a way to count the specific active nativeHistogram series in the head and hence this PR uses the activeNativeHistograms series count from Cortex - which differs in the way activeSeries is counted.

Checklist

  • Tests updated
  • Documentation added
  • CHANGELOG.md updated - the order of entries should be [CHANGE], [FEATURE], [ENHANCEMENT], [BUGFIX]

Copy link
Contributor

@harry671003 harry671003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall changes looks good. Please add tests.

@@ -1,6 +1,7 @@
# Changelog

## master / unreleased
* [ENHANCEMENT] Ingester: Add activeSeries limit specifically for NativeHistograms. #6796
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changelog item needs to be grouped with other enhancement items

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Updated.

@PaurushGarg PaurushGarg changed the title Add active series limit for nativeHistograms samples Add active series limit for nativeHistogram samples Jun 24, 2025
Signed-off-by: Paurush Garg <[email protected]>
Signed-off-by: Paurush Garg <[email protected]>
Signed-off-by: Paurush Garg <[email protected]>
Signed-off-by: Paurush Garg <[email protected]>
Signed-off-by: Paurush Garg <[email protected]>
@PaurushGarg PaurushGarg force-pushed the native-histograms-active-series-limit branch from 024c1e9 to ab7970d Compare June 24, 2025 19:16
@PaurushGarg PaurushGarg marked this pull request as ready for review June 24, 2025 19:16
@@ -3606,6 +3606,11 @@ The `limits_config` configures default and per-tenant limits imposed by Cortex s
# CLI flag: -ingester.max-series-per-metric
[max_series_per_metric: <int> | default = 50000]

# The maximum number of active native histogram series per user, per ingester. 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add to the description that this limit needs active series tracker to be enabled.

Copy link
Contributor Author

@PaurushGarg PaurushGarg Jun 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks updated.
Added check of activeSeriesMetricsEnabled to the earlier MaxGlobalNativeHistogramSeriesPerUser validation of shardByAllLabels. and to the MaxLocalNativeHistogramSeriesPerUser

@@ -448,6 +448,11 @@ func (u *userTSDB) PreCreation(metric labels.Labels) error {
}
}

// Total nativeHistograms series limit.
if err := u.limiter.AssertMaxNativeHistogramSeriesPerUser(u.userID, u.activeSeries.ActiveNativeHistogram()); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can activeSeries be nil? Should we handle for that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think null check should not be required as preallocation is done while initialization: https://github.com/cortexproject/cortex/blob/master/pkg/ingester/active_series.go#L44

Signed-off-by: Paurush Garg <[email protected]>
Signed-off-by: Paurush Garg <[email protected]>
Signed-off-by: Paurush Garg <[email protected]>
Copy link
Contributor

@harry671003 harry671003 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants